# -*- coding: utf-8 -*-
# filename: handle.py

import json
from lottery.view import mysql_util

def get_bull_avai(request):
    try:
        conn = mysql_util.getconn()
        conn.execute("select message,mobile from bullet where passes='no'")
        persons = conn.fetchall()
        pdata = []
        for person in persons:
            pdata.append(person[0])
            conn.execute("update bullet set passes='yes' where mobile=%s",(person[1]))
        datadict = {}
        datadict['data'] = pdata
        datadict['result'] = True
        return json.dumps(datadict)
    except Exception as e:
        return e.args

